<template>
  <a-tree v-model:expandedKeys="expandedKeys" :tree-data="treeData" @select="handleselect">
    <template #title="{ key: treeKey, title }" #default="{ node, treeData }">
      <a-dropdown :trigger="['contextmenu']" @click="handleToAdminList">
        <span>{{ title }}</span>
      </a-dropdown>
    </template>
  </a-tree>
</template>
<script lang="ts" setup>
import { watch, ref } from 'vue'
import { computed } from 'vue'
import { useTestExplainkListStore } from '@/stores/testbank/testexplain/testexplainlist'
import { useRouter } from 'vue-router'
const router = useRouter()
const testExplainkListStore = useTestExplainkListStore()
testExplainkListStore.testExplianListResultAction()

const expandedKeys = ref<string[]>(['0', '1'])

watch(expandedKeys, () => {
  console.log('expandedKeys', expandedKeys)
})

interface Tree {
  title: string
  iid?: number
  children?: Tree[]
}

const treeData = computed(() => testExplainkListStore.testExplainlistDatas)
console.log(treeData, '请求申论分类数据')

let iid = ref(0)
const handleselect = (treeData: Tree, node) => {
  console.log(treeData.title, '这是点击标题的iid', node.node.iid)
  iid = node.node.iid
  router.push({
    path: `/testexplaindetail/${iid}`,
  })
}

function handleToAdminList(treeData: Tree, node) {
  console.log('点击分累了', node)

  //   router.push({
  //     path: `/testbankdetail/${iid}`,
  //    })
}
</script>

<style scoped></style>
